//
//  JWFindFreightReleaseVC.m
//  jinwang
//
//  Created by jzb on 2018/4/13.
//  Copyright © 2018年 jzb. All rights reserved.
//

#import "JWFindFreightReleaseVC.h"
#import "JWFBFacadeVCModel.h"
#import "JWFindBussinessReleaseExitVC.h"

@interface JWFindFreightReleaseVC ()

@property (weak, nonatomic) IBOutlet UILabel *TypeLabel;

@property (weak, nonatomic) IBOutlet UITextField *TitleTF;
@property (weak, nonatomic) IBOutlet UILabel *ValueLabel;
@property (weak, nonatomic) IBOutlet UILabel *OrderAddressLabel;
@property (weak, nonatomic) IBOutlet UILabel *BuyTypeLabel;


@property (nonatomic,strong) NSMutableArray *list;

@property (nonatomic,strong)NSMutableArray *imageMarkArray;//图片对应的记号`0`表示第0张图片
@property (nonatomic,strong)NSMutableArray *imageUploadedNameArray;//所有上传图片名字数组（上传图片之后，返回的名字）
@property (nonatomic,strong)NSMutableArray *imageUploadedArray;//图片数组
@property (nonatomic,strong)NSMutableArray *imageDownloadedNameArray;//之前上传的oldHtmlString解析出来的图片地址

@property (nonatomic,assign) BOOL hasEndDiv;
@property (nonatomic,assign) BOOL hasHeadDiv;
@property (nonatomic,assign) NSInteger imageIndex;

@property (strong, nonatomic) UIView *pickerBGView;
@property (strong, nonatomic) UIPickerView *pickerView;
@property (strong, nonatomic) JWFBFacadeVCModel *selectModel;

@property (strong, nonatomic) NSAttributedString *AttributedString;
@property (nonatomic,strong) NSMutableString *resultString;//拼接之后的字符串



@end

@implementation JWFindFreightReleaseVC

- (void)viewDidLoad {
    [super viewDidLoad];
    self.title = @"发布";
    if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 7.f) {
        self.edgesForExtendedLayout = UIRectEdgeNone;
    }
    
}

- (IBAction)typeBtnOnclick:(UIButton *)sender {
}
- (IBAction)ValueBtnOnclick:(UIButton *)sender {
    
    JWFindBussinessReleaseExitVC *VC = [JWFindBussinessReleaseExitVC new];
    
    VC.ExitBlcok = ^(NSAttributedString *AttributedString) {
        
        NSLog(@"0-0--=-=-=-=>>>%@",AttributedString);
        if (AttributedString.length > 0) {
            _AttributedString = AttributedString;
            self.ValueLabel.text = @"已编辑";
            _ValueLabel.textColor = kRGBColor(100, 100, 100);
        }else{
             self.ValueLabel.text = @"请输入内容";
            _ValueLabel.textColor = [UIColor lightGrayColor];
        }
    };
    
    if (_AttributedString.length > 0) {
        
        VC.ExitAttributedString = _AttributedString;
    }
    
    [self.navigationController pushViewController:VC animated:YES];
}
- (IBAction)OrderAddressBtnOnclick:(UIButton *)sender {
}
- (IBAction)buyTypeBtnOnclick:(UIButton *)sender {
}
- (IBAction)LiJiFaBuBtnOnclick:(UIButton *)sender {
}

//快急商务获取更多标签
-(void)makeUrl_Business_allTag{
    [[DDNetworkManagerDate makeUrl_Business_allTagWithtoken:k_user_token] post_RequestFinshSuccess:^(id responseObject) {
        if ([self requestFinshCode:responseObject isShowMessage:NO] == 1) {
            _list = [NSMutableArray new];
            NSArray *data = [responseObject objectForKey:kRequsetDataKey];
            //转模型
            NSMutableArray *arr = [NSMutableArray array];
            [data enumerateObjectsUsingBlock:^(id  _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
                JWFBFacadeVCModel *model = [JWFBFacadeVCModel yy_modelWithDictionary:obj];
                [arr addObject:model];
            }];
            self.list = arr.mutableCopy;
            if (_list.count > 0) {
                _selectModel = self.list[0];
            }
        }
        [self.pickerView reloadAllComponents];
    } failure:^(id errorObject) {
        
        [self showBottomMessag:@"网络请求失败"];
    }];
}
//发布快急商务
-(void)makeUrl_Business_addBusiness{
    [[DDNetworkManagerDate makeUrl_Business_addBusinessWithtoken:k_user_token tag_id1:[_selectModel.tag_id stringValue] tag_id2:@"" business_title:_TitleTF.text business_content:self.resultString day:@"1"] post_RequestFinshSuccess:^(id responseObject) {
        if ([self requestFinshCode:responseObject isShowMessage:YES] == 1) {
            [self goBack];
        }
    } failure:^(id errorObject) {
        
        [self showBottomMessag:@"网络请求失败"];
    }];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end
